<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>相册分类列表</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/ui/activity/publish_act.css">
    <link rel="stylesheet" href="${ctx}/static/uploadCI/upload.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

    <style type="text/css">
        .tip {
            border: 1px solid #efefef;
            border-radius: 5px;
            padding-left: 30px;
            padding-top: 10px;
            padding-bottom: 10px;
            font-size: 18px;
            color: #000000;
            letter-spacing: 1px;
            width: calc(100% - 280px);
        }

        .tip span {
            padding-left: 5px;
            padding-right: 5px;
        }
    </style>
</head>
<c:set var="copartner" value="false" scope="page"/>
<shiro:hasRole name="copartner">
    <c:set var="copartner" value="true" scope="page"/>
</shiro:hasRole>
<!--头部-->
<c:if test="${copartner == true}">
    <%@include file="../include/header.jsp" %>
</c:if>
<c:if test="${copartner == false}">
    <%@include file="../include/editHeader.jsp" %>
</c:if>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="add-form-content">
                <div class="f-search-bar">
                    <form class="layui-form" action="${ctx}/photo/album/third/list.do" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <input type="hidden" name="photosId" value="${photosTag.photosId}"/>

                        <div style="margin-bottom: 80px">
                            <div class="layui-form-item" style="width: 1335px;float: left">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-block" style="margin-left: 350px">
                                    <div class="tip" style="float: left">权限:你可以<span class="red">1.上传照片 2.添加分类 3.移动照片 4.设为精选 5.可以删除自己上传</span>
                                    </div>
                                </div>
                            </div>
                            <div class="buttons mt20">
                                <a class="layui-btn layui-btn-danger"
                                   href="javascript:txz.openQrDialog({
                                                            title:'扫码二维码可预览分享',
                                                            detailList:[{
                                                                title:'相册详情二维码',
                                                                url:'${qrcodeUrl}',
                                                                link:''
                                                            }]
                                                        })">二维码</a>
                            </div>
                        </div>
                        <div class="layui-form-item" style="margin-left: 65px;letter-spacing: 1px;font-size: 15px">
                            <div>相册名称：${photoProject.name}</div>
                            <div style="margin-top: 8px">发布者：${photoProject.memberName}</div>
                        </div>
                        <div style="border-bottom:1px solid; border-bottom-color:#d7d7d7;">
                        </div>
                    </form>
                    <div class="buttons mt20" style="text-align: right">
                        <a class="layui-btn layui-btn-primary"
                           href="javascript:addAlbum('', '${photosTag.photosId}')">创建分类</a>
                        <a class="layui-btn layui-btn-danger"
                           href="javascript:uploadPic('', '${photosTag.photosId}')">上传照片</a>
                    </div>
                    <div class="my-act-list-content">
                        <ul id="view">
                            <table class="layui-table">
                                <colgroup>
                                    <col width="25%">
                                    <col width="25%">
                                    <col width="25%">
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>分类名称</th>
                                    <th>照片数量</th>
                                    <th>修改时间</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="album" items="${list}">
                                    <tr>
                                        <td>${album.name}</td>
                                        <td>${album.imgNum}</td>
                                        <td>
                                            <fmt:formatDate value="${album.updateDate}" pattern="yyyy-MM-dd HH:mm"/>
                                        </td>
                                        <td>
                                            <div class="opts-btns tb-opts">
                                                <div class="comm-opts">
                                                    <c:if test="${album.name != '热门' && album.name != '精选'}">
                                                        <a href="javascript:uploadPic('${album.id}', '${album.photosId}')">
                                                            上传照片
                                                        </a>
                                                    </c:if>
                                                    <a href="${ctx}/photo/album/third/Imglist.do?albumId=${album.id}"
                                                       target="_self">
                                                        照片管理
                                                    </a>
                                                    <c:if test="${album.type == 1 && album.createBy == currentUserId}">
                                                        <a href="javascript:addAlbum('${album.id}', '${album.photosId}');">
                                                            编辑
                                                        </a>
                                                    </c:if>
                                                </div>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </ul>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div>
        <c:if test="${copartner == true}">
            <!--底部-->
            <%@include file="../include/footer.jsp" %>
        </c:if>
    </section>
</div>

<!--底部-->
<%@include file="../include/editFooter.jsp" %>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/common.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });

    });

    function addAlbum(albumId, photosId) {
        var str;
        if (albumId) {
            str = '编辑';
        } else {
            str = '创建';
        }
        openDialog(str + '分类', '${ctx}/photo/album/third/addAlbum.do?id=' + albumId + '&photosId=' + photosId, '436px', '239px');
    }

    function openDialog(title, url, width, height, cb, target) {
        var index = layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }
            },
            cancel: function (index) {
            },
            success: function () {
                $(':focus').blur();
            }
        });
    }


    function uploadPic(albumId, photosId) {
        txz.openThirdPhotoUpload({
            tagId: albumId,
            id: photosId
        })
    }
</script>
</body>
</html>